package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils.TruncateAt;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import com.huawei.appgallery.foundation.card.base.normal.bean.NormalCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import java.util.List;
import o.azb;
import o.cgz;
import o.chc;
import o.chy;
import o.clp;
import o.eiw;
import o.epv;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class DoubleHorizontalSmallEntranceItemCard extends BaseHorizontalItemCard {
    private View ʻ;
    private View ʼ;
    private SmallLanternCard ʽ;
    private SmallLanternCard ˋ;
    private LinearLayout ͺ;
    private boolean ॱॱ = false;
    private int ᐝ;

    public DoubleHorizontalSmallEntranceItemCard(Context context) {
        super(context);
    }

    private int ॱॱ() {
        return chc.ʾ();
    }

    private SmallLanternCard ˎ(Context context) {
        return new SmallLanternCard(context);
    }

    public cgz ˏ(View view) {
        this.ͺ = (LinearLayout) view.findViewById(j.ᵢॱ);
        this.ʼ = view.findViewById(j.ʽᵎ);
        this.ʼ.setPaddingRelative(0, this.ʼॱ.getResources().getDimensionPixelSize(d.ˋ), 0, this.ʼॱ.getResources().getDimensionPixelSize(d.ॱ));
        this.ˋ = ˎ(this.ʼॱ);
        this.ˋ.ˏ(this.ʼ);
        this.ˋ.ˊˋ().setSingleLine(true);
        this.ˋ.ˊˋ().setEllipsize(TruncateAt.END);
        this.ʻ = view.findViewById(j.ʽᵔ);
        this.ʻ.setPaddingRelative(0, this.ʼॱ.getResources().getDimensionPixelSize(d.ॱ), 0, this.ʼॱ.getResources().getDimensionPixelSize(d.ॱ));
        this.ʽ = ˎ(this.ʼॱ);
        this.ʽ.ˏ(this.ʻ);
        this.ʽ.ˊˋ().setSingleLine(true);
        this.ʽ.ˊˋ().setEllipsize(TruncateAt.END);
        ʽ(view);
        if (this.ʼॱ instanceof eiw) {
            this.ॱॱ = true;
            this.ᐝ = this.ʼॱ.getResources().getConfiguration().orientation;
        }
        ʻ();
        return this;
    }

    public void ˋ(List<CardBean> list) {
        if (this.ॱॱ) {
            int i = this.ʼॱ.getResources().getConfiguration().orientation;
            if (i != this.ᐝ) {
                this.ᐝ = i;
                ʻ();
            }
        }
        int size = list.size();
        for (int i2 = 0; i2 < size; i2++) {
            ˋ(i2, (CardBean) list.get(i2));
        }
        if (size == 1) {
            this.ʻ.setVisibility(8);
        }
    }

    private void ʻ() {
        ˉ().setLayoutParams(new LayoutParams(epv.ˎ(this.ʼॱ, ॱॱ(), chc.ˋ() * 2), -2));
    }

    private void ˋ(int i, CardBean cardBean) {
        if (i == 0) {
            ˎ(this.ˋ, cardBean);
        } else if (1 == i) {
            ˎ(this.ʽ, cardBean);
        }
    }

    private void ˎ(SmallLanternCard smallLanternCard, CardBean cardBean) {
        smallLanternCard.ˏ(cardBean);
    }

    public int ˊ() {
        return h.ˑᐝ;
    }

    public int ˎ() {
        return h.ˑᐝ;
    }

    public void ॱ(chy o_chy) {
        this.ˋ.ॱ(o_chy);
        this.ʽ.ॱ(o_chy);
    }

    public void ˋ(clp<? extends NormalCardBean> o_clp__extends_com_huawei_appgallery_foundation_card_base_normal_bean_NormalCardBean) {
        super.ˋ((clp) o_clp__extends_com_huawei_appgallery_foundation_card_base_normal_bean_NormalCardBean);
        if (o_clp__extends_com_huawei_appgallery_foundation_card_base_normal_bean_NormalCardBean.ॱ() != null) {
            int size = o_clp__extends_com_huawei_appgallery_foundation_card_base_normal_bean_NormalCardBean.ॱ().size();
            if (size < ॱॱ() * 2) {
                int ˋ = chc.ˋ();
                int ॱ = (azb.ॱ(this.ʼॱ) - (((ॱॱ() - 2) * ˋ) * 2)) / ॱॱ();
                if (size <= ॱॱ()) {
                    size = epv.ˎ(this.ʼॱ, size, ˋ);
                } else {
                    size = ॱ;
                }
                this.ͺ.setOrientation(0);
                ˉ().setLayoutParams(new LayoutParams(-2, -2));
                LayoutParams layoutParams = (LayoutParams) this.ʼ.getLayoutParams();
                layoutParams.width = size;
                if (this.ʻ.getVisibility() != 8) {
                    layoutParams.setMarginEnd(ˋ * 2);
                }
                this.ʼ.setLayoutParams(layoutParams);
                this.ʻ.setPaddingRelative(0, this.ʼॱ.getResources().getDimensionPixelSize(d.ˋ), 0, this.ʼॱ.getResources().getDimensionPixelSize(d.ॱ));
                layoutParams = (LayoutParams) this.ʻ.getLayoutParams();
                layoutParams.width = size;
                this.ʻ.setLayoutParams(layoutParams);
            }
        }
    }
}
